/*
 * @lc app=leetcode.cn id=225 lang=csharp
 *
 * [225] 用队列实现栈
 */

// @lc code=start
public class MyStack {
    Queue<int> queueIn;
    Queue<int> queueOut;
    public MyStack() {
        queueIn = new Queue<int>();
        queueOut = new Queue<int>();
    }
    
    public void Push(int x) {
        queueIn.Enqueue(x);
        while (queueOut.Count > 0) {
            queueIn.Enqueue(queueOut.Dequeue());
        }
        Queue<int> temp = queueIn;
        queueIn = queueOut;
        queueOut = temp;
    }
    
    public int Pop() {
        return queueOut.Dequeue();
    }
    
    public int Top() {
        return queueOut.Peek();
    }
    
    public bool Empty() {
        return queueOut.Count == 0;
    }
}

/**
 * Your MyStack object will be instantiated and called as such:
 * MyStack obj = new MyStack();
 * obj.Push(x);
 * int param_2 = obj.Pop();
 * int param_3 = obj.Top();
 * bool param_4 = obj.Empty();
 */
// @lc code=end

